package dome.common;

import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;
import java.net.URL;

public class SceneSwicher {
    public static void switchTo(Node node, String fxmlPath) throws IOException {
        Stage stage = (Stage) node.getScene().getWindow();
        FXMLLoader fxmlLoader = new FXMLLoader();
        URL url = SceneSwicher.class.getResource("../view/"+fxmlPath);
        fxmlLoader.setLocation(url);
        Parent root = fxmlLoader.load();
        Scene scene = node.getScene();
        scene.setRoot(root);
        stage.setScene(scene);
        stage.show();
    }
}
